﻿using System.Threading.Tasks;

namespace BookSourceVerification.handlers;

public interface IHandler<in T>
{
    public bool IsChecked(T node, HandlerResult result);

    public Task Handler(T node, HandlerResult result)
    {
        if (!IsChecked(node, result))
        {
            return Task.CompletedTask;
        }

        return DoHandler(node, result);
    }

    /// <summary>
    /// 测试 node json是否满足条件
    /// </summary>
    /// <param name="node"></param>
    /// <param name="result"></param>
    /// <returns>true：满足条件，false：不满足条件，该node节点被淘汰</returns>
    public Task DoHandler(T node, HandlerResult result);

    public void AfterHandler();
}